package com.wpw;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.wpw.filter.MyFilter;
/**
 * spring会扫描该类将filter加入进去
 * 
 * Project Name：springboot-demo
 * ClassName：WebConfiguration
 * Description：
 * @author: wupengwei
 * @date: 2017年12月28日 下午4:02:50
 * note:
 *
 */
@Configuration
public class WebConfiguration {
	
	/*@Bean
    public RemoteIpFilter remoteIpFilter() {
        return new RemoteIpFilter();
    }*/
    
    @Bean
    public FilterRegistrationBean testFilterRegistration() {

        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new MyFilter());
        registration.addUrlPatterns("/*");
        registration.addInitParameter("paramName", "paramValue");
        registration.setName("MyFilter");
        registration.setOrder(2);
        System.out.println("=============================加入了filter======================");
        return registration;
    }
}
